package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Article;
import cn.wolfcode.trip.base.service.IArticleService;
import cn.wolfcode.trip.base.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("article")
public class ArticleController {

    @Autowired
    private IArticleService articleService;

    @Autowired
    private IUserService userService;

   /* @PostMapping
    public JSONResult save(){
        return null;
    }*/

    @GetMapping
    public List<Article>getAllArticle(){
        return articleService.queryForList();
    }


    @GetMapping(value = "/{articleId}")
    public Article getArticleDetail(@PathVariable("articleId") Long articleId,Model moel){
        moel.addAttribute("article",articleService.getArticleDetailByArticleId(articleId));
        return articleService.getArticleDetailByArticleId(articleId);
    }



}
